home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / bbs / qb281cz2.zip / STRUCT.ZIP / C.ZIP / TEST.CPP < prev   
C/C++ Source or Header  |  1995-04-22  |  3KB  |  118 lines

  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <io.h>
  4. #include <fcntl.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. #include <sys\stat.h>
  8. #include <alloc.h>
  9. #include <iostream.h>
  10. #include "quick280.hpp"
  11.  
  12. /* Uncomment the next line for GOLDBASE */
  13. //#define GOLDBASE
  14.  
  15. #ifdef GOLDBASE
  16. Integer  MaxMsgAreas  = 500;
  17. Char     FileExt[] = ".DAT";
  18. #else
  19. Integer  MaxMsgAreas  = 200;
  20. Char     FileExt[] = ".BBS";
  21. #endif
  22. Integer  MaxLanguages = 30;
  23. Integer  MaxEvents    = 30;
  24. Integer  MaxProtocols = 20;
  25.  
  26. int FileHandle, FileBytes;
  27. struct ConfigRecord *CFG;
  28. struct ConfigRecord *CFGtxt;
  29. struct UserRecord *User;
  30. struct UserRecord *Usertxt;
  31.  
  32. char *YesNo[2]=
  33. {
  34. "No","Yes",
  35. };
  36.  
  37. char *OnOff[2]=
  38. {
  39. "Off","On",
  40. };
  41.  
  42. Integer BitValue[8]=
  43. {
  44. 1,2,4,8,16,32,64,128,
  45. };
  46.  
  47. char *AttributeText[16]=
  48. {
  49. "No","Yes","No","Yes","No","Yes","No","Yes",
  50. "No","Yes","No","Yes","No","Yes","Male  ","Female",
  51. };
  52.  
  53.  
  54. void CLS();
  55. void ShowBoolean (char *TheText,Boolean MyBoolean);
  56. void ShowText (char *TheText,Byte LOS,char *TheString);
  57. void ShowAttribute(char *TheText,Byte AttributeInfo, Integer Attribute);
  58.  
  59. void CLS()
  60. {
  61.     clrscr();
  62. }
  63.  
  64.  
  65. void ShowBoolean (char *TheText,Boolean MyBoolean)
  66. {
  67.     printf("%s%s\n",TheText,YesNo[MyBoolean]);
  68. }
  69.  
  70. void ShowText (char *TheText,Byte LOS,char *TheString)
  71. {
  72.     printf("%s%.*s\n",TheText,LOS,TheString);
  73. }
  74.  
  75.  
  76.  
  77. void ShowAttribute(char *TheText,Byte AttributeInfo, Integer Attribute)
  78. {
  79.     Integer TheAttribute;
  80.     TheAttribute = AttributeInfo & BitValue[Attribute];
  81.     if (TheAttribute > 0)
  82.     TheAttribute=1;
  83.     printf("%s%s\n",TheText,AttributeText[((Attribute+1)*2-2)+TheAttribute]);
  84.  
  85. }
  86. void main(void)
  87. {
  88.     FILE *MyFile;
  89.     CLS();
  90.  
  91.     CFG = (struct ConfigRecord*) malloc(sizeof(struct ConfigRecord));
  92.     if ((FileHandle=open("QuickCFG.dat",O_RDONLY|O_BINARY)) != -1)
  93.         {
  94.         FileBytes = read(FileHandle,CFG,sizeof(struct ConfigRecord));
  95.         close(FileHandle);
  96.         fclose(MyFile);
  97.         }
  98.  
  99.     User = (struct UserRecord*) malloc(sizeof(struct UserRecord));
  100.     if ((FileHandle=open("Users.dat",O_RDONLY|O_BINARY)) != -1)
  101.         {
  102.         FileBytes = read(FileHandle,User,sizeof(struct UserRecord));
  103.         close(FileHandle);
  104.         fclose(MyFile);
  105.         }
  106.  
  107.     CFGtxt = CFG;
  108.     Usertxt = User;
  109.     ShowText("Editor Command String - ",CFGtxt->EditorCmdStr.LengthOfString,CFGtxt->EditorCmdStr.TheString);
  110.     ShowText("BBS Location - ",CFGtxt->Location.LengthOfString,CFGtxt->Location.TheString);
  111.     ShowBoolean("Ask For Home Phone Number - ",CFGtxt->AskHomePhone);
  112.     ShowText("User's Name - ",Usertxt->Name.LengthOfString,Usertxt->Name.TheString);
  113.     ShowAttribute("The User is a ",Usertxt->Attrib,7);
  114.     free(User);
  115.     free(CFG);
  116. }
  117.  
  118.